saline_singularityfandomcom-20200213-history
Programming Quick Start
Setting up the Coding Environment Getting Eclipse and WPILib Check out the WPILib Screensteps for your year (this website has the 2016 directions) to learn how to download and correctly configure the Eclipse development environment. If Eclipse is already installed, skip that part of the tutorial and move on to the WPILib installation section. Integrating JSON.Simple (and Other External Libraries) #Grab the .zip archive from here and extract it to some directory (make sure to remember where!). #In Eclipse, on the top toolbar, go to Window -> Preferences. Next, expand the Java section, and then the Build Path section. Finally, choose User Libraries. #Press New to create a new library. Call it "JSON.simple" (without the quotes. Actually, any name works, but make it memorable). Press Okay. #Make sure that the library you just created is highlighted. Press Add External JARS, navigate to the JSON jar, and press Okay. The library is now set up. We just have to add it to your project now. #Exit out of the prefences window. At the top of the Eclipse window, go to Project -> Properties. #Choose Java Build Path in the sidebar. #On the right hand side of the window, choose Add Library. Pick the library which your just created, and press Okay. #Exit out of the properties window, and your project should now be completely able to handle JSON. Setting up EGit (Git Integration) #Open Eclipse and, at the top, navigate to Help -> Install New Software. #Type "http://download.eclipse.org/egit/updates" into the dialog box. Press Add and wait. #Select all of the checkboxes and press Next a bunch of times. #Restart Eclipse, and EGit should be up and running. Compilation To compile the code, make sure you are connected to the robot. Then just press the green arrow and choose WPILib Java Deploy. The code should then push to the robot. See build.properties and build.xml to see more about the compilation process. Starting a Project -- Singularity Style WPILib has their own tutorials for starting basic robot projects, but this is how we do it here on the Saline Singularity. Creating the Project # In Eclipse, navigate to File -> New -> Other # Under WPILib Java Robot Development, select "Robot Java Project" and then click Next. # Name the new project (our naming convention is "FRCyear") and choose the Iterative Robot* radio button. Then click Finish. *NOTE: In future years it might make sense to switch to a Command-Based Robot, but in 2016 we still used the Iterative Robot scheme. Adding the Singularity Libraries Our team has been developing our own libraries to extend WPILib's functionality since the 2015 season. The libraries streamline the robot coding process by providing many classes and methods that are useful to our team every year, such as the SingularityDrive class that extends the basic RobotDrive class. The libraries are developed each year at the same time as the robot code, with the distinction between the two being that the robot code is for code unique to that year's game and the libraries are for code that is applicable to future years' games as well. Adding the Project to Git and GitHub # First we must create the repository on GitHub. Go to the SalineSingularityFRC GitHub page and create click the "New Repository" button. Name it "FRCyear", add a description, and make it private if possible. Then click "Create Repository" # Copy the URI (the link under "Quick setup") to your clipboard. Leave the window open in case you need to copy it again later. # Create an empty folder on your PC for the local repository (probably in the git folder) # Right-click on the project in Eclipse and navigate to Team -> Share Project... # Press the "Create..." button, then navigate to the folder you created, then click "Finish" # Click "Finish" on this menu # Now it's time for the initial commit. Right click on the project in Eclipse and navigate to Team -> Commit. Type "initial commit" into the commit message, and then click "Commit and Push" # A window will appear and prompt you to configure a remote repository. The remote repository will be set up through GitHub. Paste the URI from step 2 in the "URI" prompt in the "Location" box. Sign in with your GitHub ID* in the "Authentification" box. Then click "Next >" # Finally, click "Next >" and then "Finish." *The account must have the correct privileges on the Saline Singularity GitHub) Importing the Project on Another Computer (from Github) # Navigate to File -> Import # In the folder Git, choose Projects from Git and click "Next" # Choose Clone URI and click "Next" # Enter your GitHub credentials under "Authentfication" and copy-paste the URI from GitHub into the URI box. Then hit "Finish" Running Code # Make sure you are connected to the robot's wifi network. # Click the green "run" button in Eclipse and select WPILib Java Deploy. Alternatively, right-click in the Robot.java file and select Run As -> WPILib Java Deploy # Wait for the build-and-push process* to (hopefully) complete. You'll know it is complete when the console displays "BUILD SUCCESSFUL". If the console displays "BUILD FAILED," refer to BUILD FAILED. # The code will run automatically on the robot once it is pushed. On the driver dashboard, you should see a green light next to "Robot code". If not, restart the robot. (If that doesn't solve the problem, refer to the Errors database on this wiki). # Select teleop, automomouns, test, or practice mode in Driver Station, then click the green "Enable" button! For more about the build process, refer to Build.properties and build.xml.Category:Programming Category:Training